package com.zhanglei.method;

/**
 * @author caesar
 * @date 2025/7/7
 * @apiNote
 */
public class Student {
    private String name;
    private int score;

    public Student() {
    }

    public Student(String name, int score) {
        this.score = score;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }
    //一般不考虑将排序等算法封装成方法，因为使用的话，需要使用对象来调用方法，比较奇怪
    //如果想要封装，也不需要返回值类型，因为传入的是数组，对应的是引用类型，可以直接对数组内的值进行修改
    public static  void BubbleSort(Student[] students){
        for(int i=1; i<students.length; i++){
            for(int j=0; j<students.length - i; j++){
                if(students[j].getScore() > students[j+1].getScore()){
                    Student temp = students[j];
                    students[j] = students[j+1];
                    students[j+1] = temp;
                }
            }
        }

    }
    public String display() {
        return "姓名：" + name + "，成绩：" + score;
    }
}
